<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>空型号</title>

        <link rel="stylesheet" type="text/css" href="/webapp/css/easyui.css">
        <link rel="stylesheet" type="text/css" href="/webapp/css/icon.css">
        <link rel="stylesheet" type="text/css" href="/webapp/css/color.css">
        <link rel="stylesheet" type="text/css" href="/webapp/css/public.css">
        <script type="text/javascript" src="/webapp/js/lib/jquery.min.js"></script>
        <script type="text/javascript" src="/webapp/js/lib/jquery.easyui.min.js"></script>
        <script type="text/javascript" src="/webapp/js/common/jquery.global.settings.js"></script>
        <script type="text/javascript" src="/webapp/js/lib/ajaxfileupload.js"></script>
        <script type="text/javascript" src="/webapp/js/common/config.js"></script>
        <!--字段解释
            剩余条数、剩余空型号总量必须有筛选条件， 举例，比如彩电一共500条空型号，销量大于10时候，需要处理空型号就是400条，剩余空型号（销量小于等于10）100条，
            剩余空型号总量：这个100条的量一共是多少，剩余量占比：100条量占比多少-->
    </head>
    <body>
        <div class="easyui-container-fluid">
            <div class="easyui-panel" style="border: none;">
                <div class="nav" id="nav"></div>
                <div class="easyui-panel" style="border:none;">
                    <form id="ff" method="post">
                        <div style="margin-bottom: 20px;">
                            <label class="item-label">年：</label>
                            <input type="text" id="year" name="year" class="easyui-combobox" data-options="required:true" required="required" style="width: 100px;"/>
                            <span id="monthLabel">
                                <label class="item-label">月：</label>
                                <input type="text" id="month" name="month" class="easyui-combobox" data-options="required:true" required="required" style="width: 100px;">
                            </span>
                            <span id="weekLabel">
                                <label class="item-label">周：</label>
                                <input type="text" id="week" name="week" class="easyui-combobox" data-options="required:true" required="required" style="width: 100px;">
                            </span>
                            <label class="item-label">渠道：</label>
                            <input type="text" class="easyui-textbox" id="channel" name="channelCode"  style="width:100px;"/>
                            <label class="item-label">商场：</label>
                            <input type="text" class="easyui-textbox" id="mall" name="mallCodeMulti"  style="width:100px;"/>
                            <label class="item-label">品类：</label>
                            <select id="categorySelect" name="categoryCodes" class="easyui-combobox" style="width:100px;">
                            </select>
                            <label class="item-label">筛选条件：</label>
                            <select id="selectType" name="selectType" class="easyui-combobox" data-options="panelHeight:'auto'" style="width:5%;">
                                <option value="">-请选择-</option>
                                <option value="PRICE">价格</option>
                                <option value="COUNT">销量</option>
                            </select>
                            <select id="comparerbox" name="comparator" class="easyui-combobox" data-options="panelHeight:'auto'" style="width:5%;" prompt="比较符">
                                <option value=""></option>
                                <option value="EQUAL">=</option> 
                                <option value="GREAT_EQUAL">&gt;=</option>
                                <option value="GREAT">&gt;</option>
                                <option value="LITTLE">&lt;</option>
                                <option value="LITTLE_EQUAL">&lt;=</option>
                                <option value="NOT_EQUAL"><pre><></pre></option>
                            </select>
                            <input type="text" id="valuebox" name="value" class="easyui-textbox" prompt="数值" data-options="" style="width:4.8%"/>

                        </div>
                        <div style="margin-bottom: 20px;">

                            <label class="item-label">记录数：</label>
                            <input id="recordCountQuery" class="easyui-switchbutton" checked style="width:60px;height:30px;" onText="ON" offText="OFF"  >
                            &nbsp;量：
                            <input id="countQuery" class="easyui-switchbutton" style="width:60px;height:30px;" onText="ON" offText="OFF"   >
                            &nbsp;额：
                            <input id="totalQuery" class="easyui-switchbutton" style="width:60px;height:30px;" onText="ON" offText="OFF"   >
                            &nbsp;品牌：
                            <input id="brandOut" class="easyui-switchbutton" checked style="width:60px;height:30px;" onText="ON" offText="OFF"   >
                            <a href="javascript:void(0);" class="easyui-linkbutton c8" onclick="searchBy()" style="width:80px;margin-left: 40px;">查询</a>
                            <a href="javascript:void(0);" class="easyui-linkbutton c5" onclick="dd()" style="width:80px;margin-left: 480px;">禁用</a>
                        </div>

                    </form>
                </div>
                <div class="table-wrapper">
                    <table id="datagrid" class="easyui-datagrid" data-options="fitColumns:true,scrollbarSize:0">
                        <thead>
                        <tr>
                            <th data-options="field:'categoryName',align:'center'" width="80">品类</th>
                            <th data-options="field:'modelCount',align:'center'" formatter="sy"  width="100" >需处理条数</th>
                            <th data-options="field:'syModelCount',align:'center'"  formatter="sy" width="100" >剩余条数</th>

                            <th data-options="field:'syCountZ',align:'center'"   formatter="sy" width="100" >剩余空型号总量</th>

                            <th data-options="field:'cpercentage',align:'center'" formatter="cpercentage" width="100" >剩余量占比</th>
                            <th data-options="field:'syTotalZ',align:'center'" formatter="sy" width="100" >剩余空型号总额</th>
                            <th data-options="field:'tpercentage',align:'center'" formatter="cpercentage" width="100" >剩余额占比</th>
                        </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
        <div id="dd" class="easyui-window upload-wrapper" title="禁用空型号" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:330px;height:220px;padding:10px;">
            <span class="item-required">*注意：禁用的是剩余数据，具体条数请看[剩余条数]列</span>
            <div class='box'>

                品类：
                <select id="categoryList" class="easyui-combobox" style="width:200px;" name="categories" data-options="multiple:true"></select>

            </div>

            <div style="margin-top:20px;text-align:center">
                <a style="width:60px;height: 30px;" href="javascript:void(0);" class="easyui-linkbutton c8" onclick="findCaDisable()">保存</a>
            </div>
        </div>
    </body>
    <script>
        $(function () {
            setNav();
            // initChannelSelect("channel");
            $("#datagrid").datagrid({
                pagination: true,
                rownumbers: true,
                checkOnSelect: false
            }).datagrid("getPager").pagination({
                onSelectPage: searchBy
            });
            initCategorySelect("categoryList")
            $.when(initMonthWeek("monthLabel", "weekLabel"),initCategorySelectnew("categorySelect"));
            aRecords("空型号","/webapp/pages/check/emptyModel")
        });
        function searchBy() {
            var data = getFormData(document.getElementById("ff"));
            data.reportType=window.parent.workMode.toUpperCase();
            data.recordCount = $("#recordCountQuery").switchbutton("options").checked;
            data.count = $("#countQuery").switchbutton("options").checked;
            data.total = $("#totalQuery").switchbutton("options").checked;
            data.brandOut = $("#brandOut").switchbutton("options").checked;
            $.ajax({
                url:config.url + "/emptyModel/getData",
                type:"GET",
                data:transfer(data),

                dataType:'json',
                xhrFields:{withCredentials:true},
                beforeSend:function () {
                    $.messager.progress({
                        title:"请稍等",
                        interval:50,
                        text:"数据加载中..."
                    });
                },
                success:function(data){
                    $.messager.progress("close");
                    $("#datagrid").datagrid("loadData", data);
                },
                error:function(data){
                    console.log(data);
                    $.messager.progress("close");
                }
            });
        }
        $("#ff").keydown(function (event) {
            var e = event || window.event;
            var keyCode = e.keyCode || e.which;
            if(keyCode=="13"){
                searchBy();
            }
        });
        function cpercentage(val, row) {
            if(val)
                return val + '%';
            else
                return '0.00%';
        }
        function sy(val, row) {
            if(val)
                return val ;
            else
                return '0';
        }
        function dd() {
            $("#dd").window("open");
        }
        //根据品类条件禁用销售数据
        function findCaDisable() {
            var categoryList = $("#categoryList").combotree("getValues");//.toString()
            if((categoryList.length==1 && !categoryList[0]) ||categoryList.length==0){
                $.messager.alert("错误","请选操作品类","error");
                return;
            }
            var data = getFormData(document.getElementById("ff"));
            data.reportType=window.parent.workMode.toUpperCase();
            data.brandOut = $("#brandOut").switchbutton("options").checked;
            data.categoryCodes=categoryList.toString();
            $.ajax({
                url:config.url + "/emptyModel/caDisable",
                type:"get",
                data:transfer(data),
                dataType: "json",
                xhrFields:{withCredentials:true},
                beforeSend:function () {
                    $.messager.progress({
                        title:"请稍等",
                        interval:50,
                        text:"数据加载中..."
                    });
                },
                success:function(data){
                    $.messager.progress("close");
                    if(data.code==200){
                        $.messager.alert("提示",data.msg,"info",function () {
                            searchBy();
                            $("#dd").window("close");
                        });
                    }else {
                        $.messager.alert("提示",data.msg,"error");
                    }
                },
                error:function(data){
                    console.log(data);
                    $.messager.progress("close");
                }
            });
        }
    </script>
</html>